<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <a href="https://www.bilibili.com">5秒后跳转</a>
    <script>
        const a = document.querySelector('a')
        let num = 5
        let timerID = setInterval(function () {
            num--
            a.innerHTML = `${num}秒后跳转`
            if (num === 0) {
                clearInterval(timerID)
                // 跳转页面
                location.href = "https://www.bilibili.com"
            }
        }, 1000);

    </script>
</body>

</html>